// run: $exec < input
#include <iostream>

int n, x;

int main()
{
	std::cin >> n >> x;
	int ans = 0, last = 1;
	for (int i = 0; i < n; i++) {
		int l, r;
		std::cin >> l >> r;
		while (last + x <= l) last += x;
		ans += (r - last + 1);
		last = r + 1;
	}
	std::cout << ans << '\n';
}

